package net.projecteuler.prob;

import java.util.List;

import net.projecteuler.util.PrimeUtil;

public class Problem50 implements Runnable {

	@Override
	public void run() {
		List<Integer> primeList = PrimeUtil.PrimeList;
		
		int LIMIT = 1000000;
		int maxLength = 0;		
		
		for(int idx1 = 0; idx1 < primeList.size(); idx1++){
			if(primeList.get(idx1) > LIMIT)
				break;
			
			int sum = 0;
			for(int idx2 = idx1; idx2 < primeList.size(); idx2++){
				sum += primeList.get(idx2);
				if(sum > LIMIT)
					break;
				if(PrimeUtil.isPrime(sum)){
					if(idx2 - idx1 + 1 > maxLength){
						System.out.println(sum + " : " + idx1 + "~" + idx2);
						maxLength = idx2 - idx1 + 1;
					}
				}
			}
		}
	}

}
